home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / 1svga.zip / LINE320.PAS < prev    next >
Pascal/Delphi Source File  |  1994-04-21  |  1KB  |  43 lines

  1. uses Txt;
  2.  
  3. { ─────────────── Line320 ─────────────── }
  4. procedure Line320(X1,Y1,X2,Y2,Color:integer);
  5. const
  6.   MinX:integer=0;   MinY:integer=0;
  7.   MaxX:integer=320; MaxY:integer=200;
  8. var M,I,D,Dx,Dy,IncX,IncY,IncA,IncB:integer;
  9. begin
  10.   if ((Y1<MinY) and (Y2<MinY)) or ((Y1>MaxY) and (Y2>MaxY))
  11.     or ((X1<MinX) and (X2<MinX)) or ((X1>MaxX) and (X2>MaxX)) then Exit;
  12.   if X1<MinX then X1:=MinX; if X1>MaxX then X1:=MaxX;
  13.   if X2<MinX then X2:=MinX; if X2>MaxX then X2:=MaxX;
  14.   if Y1<MinY then Y1:=MinY; if Y1>MaxY then Y1:=MaxY;
  15.   if Y2<MinY then Y2:=MinY; if Y2>MaxY then Y2:=MaxY;
  16.   Dx:=Abs(X2-X1); Dy:=Abs(Y2-Y1);
  17.   if Dx>=Dy then begin
  18.     if X2>X1 then IncX:=1 else IncX:=-1;
  19.     if Y2>Y1 then IncY:=320 else IncY:=-320;
  20.   end else begin
  21.     D:=Dx; Dx:=Dy; Dy:=D;
  22.     if X2>X1 then IncY:=1 else IncY:=-1;
  23.     if Y2>Y1 then IncX:=320 else IncX:=-320;
  24.   end;
  25.   D:=Dy shl 1-Dx; IncA:=D-Dx; IncB:=D+Dx;
  26.   M:=320*Y1+X1;
  27.   for I:=0 to Dx do begin
  28.     Mem[$A000:M]:=Color;
  29.     Inc(M,IncX);
  30.     if D>=0 then begin Inc(D,IncA); Inc(M,IncY); end
  31.       else Inc(D,IncB);
  32.   end;
  33. end;
  34.  
  35. var I:integer;
  36. begin
  37.   VideoMode($13);
  38.   for I:=0 to 999 do
  39.     Line320(160,100,Random(320),Random(200),I div 20+32);
  40.   Readln;
  41.   VideoMode(3);
  42. end.
  43.